$(function(){
	/*=== login window ===*/
	$("#J_loginReg").on('click',function(){
		art.dialog.open(login_url,{
			title:'用户登录',
			fixed:true,
			opacity:0.6,
			width:'580px',
			height:'360px',
			lock:true,
			drag:false
		});
	});
	
	/*=== login suc ===*/
	var $navUser = $('#J_navUser');
	var $userName = $('#J_userName');
	var $loginReg = $('#J_loginReg');
	$userName.find('a').each(function(index, element) {
        var maxwidth=7;  
		var maxTest = $userName.find('a').eq(0);
		if(maxTest.text().length>maxwidth){  
			maxTest.text(maxTest.text().substring(0,maxwidth));  
			maxTest.html(maxTest.html()+'...');  
		} 
    });
	var cookieStr = '';
	var cookieName = "mobile"; 
	var cookieValue = "";//返回cookie的value值 
	if (document.cookie && document.cookie != '') {
		var cookies = document.cookie.split(';');//将获得的所有cookie切割成数组 
		for (var i = 0; i < cookies.length; i++) {
			var cookie = $.trim(cookies[i]),//得到某下标的cookies数组
				curCookieName = $.trim(cookie.split('=')[0]); 
			if(cookieName == curCookieName){
				cookieValue = cookie.substring(cookieName.length + 1, cookie.length);
				break;
			}
		} 
	} 
	
	if (cookieValue != "" && cookieValue != null) {//如果存在指定的cookie值 
		$loginReg.hide(); // 隐藏登录按钮
	  cookieStr = decodeURI(cookieValue); 
	  var arr = cookieStr.split('|'),
	  	  userName = arr[0],
		  userLink = '',
		  aObj = '';
	  //去除html	
	  $userName.children('li').remove();
	  //赋值连接
	  if(arr[4] == 1){
		  userLink = backLink;
		  userLink ='<li class="u-login-in"><a href="'+userLink+'">管理员后台</a></li>';
	  }else{
		  
		  if(arr[1] == 2 || arr[1] == 4){
			  userLink = sellerLink;
			  userLink ='<li class="u-login-in"><a href="'+userLink+'">开发者中心</a></li>';
		  }else{
//				  userLink = '<?php echo config_item('domain_www')?>';
		  }
	  }
	  //添加html
	  aObj = '<li><a href="javascript:;"><span>'+ userName +'</span><span class="u-arrow"></span></a></li>' + userLink + '<li class="u-login-out"><a href="' + logoutLink + '">退出</a></li>';
	  $userName.append(aObj);
	  $navUser.show();
	}
	
	//删除cookie
	function delCookie(name)
	{
		var exp = new Date(); 
		exp.setTime(exp.getTime() - 1); 
		var cval=getCookie(name); 
		if(cval!=null) 
			document.cookie= name + "="+cval+";expires="+exp.toGMTString(); 
	} 
	
});